# -*- coding: utf-8 -*-
from .. import db, login_manager
from sqlalchemy.ext.declarative import declarative_base
from . import user

Base = declarative_base()


def db_save(dbs, bing=None):
	try:
		db.session.add(dbs)
		db.session.commit()
		return True
	except Exception as e:
		return False


def db_delete(dbs, bing=None):
	db.session.delete(dbs)
	db.session.commit()


def db_commit():
	db.session.commit()


# # callback function for flask-login extentsion
@login_manager.user_loader
def load_user(id):
	return user.User.query.get(int(id))
